Skip to content

fix(tools): resolve Windows build errors and harden filesystem security#318

Merged
viettranx merged 2 commits intonextlevelbuilder:mainfrom
badgerbees:fix/windows-filesystem-security
Mar 21, 2026
Merged

fix(tools): resolve Windows build errors and harden filesystem security#318
viettranx merged 2 commits intonextlevelbuilder:mainfrom
badgerbees:fix/windows-filesystem-security

Conversation

@badgerbees
Copy link
Contributor

Problem

GoClaw currently fails to build on native Windows because it uses Unix-specific syscall.Access and syscall.Stat_t APIs in internal/tools/filesystem.go. A previous attempt at fixing this (PR #132) correctly identified the "build tag" approach but introduced several security and efficiency regressions on Windows, such as bypassing the hardlink check and creating unnecessary temporary files on disk.

What This PR Fixes

This PR provides a clean, platform-separated implementation that resolves the build errors while addressing all critical feedback from the previous maintainer review:

  1. Robust Hardlink Detection (Fixed Critical [fix bug]:windows,syscall.Access、syscall.Stat_t build error #132 finding):
    Unlike the previous no-op implementation, this PR uses syscall.GetFileInformationByHandle to fetch NumberOfLinks on Windows. This ensures that hardlink-based escapes (e.g., trying to read an absolute file via a hardlink inside the workspace) are correctly blocked on Windows, matching the security parity of Linux.
  2. Side-Effect-Free Writability Check (Fixed High [fix bug]:windows,syscall.Access、syscall.Stat_t build error #132 finding):
  • Removed the logic that created real .wrchk temp files on disk.
  • Implemented a native handle check: we now attempt to open the directory with GENERIC_WRITE. This is a memory-only check that avoids the risk of "artifact leakage" if a file cleanup fails or disk I/O issues occur.
  1. Reliable Path Semantics (Fixed High [fix bug]:windows,syscall.Access、syscall.Stat_t build error #132 finding):
    Replaced the brittle strings.Split logic with a filepath.Dir traversal loop. This correctly handles volume roots (C:) and network UNC paths (\server\share), ensuring the security scanner always has a valid absolute path for each component.

To be honest I was just annoyed that I couldn't build and saw that someone had tried to fix this issue before but went missing so I decided to continue their work

badgerbees and others added 2 commits March 21, 2026 00:20
Now that checkHardlink uses GetFileInformationByHandle on Windows,
the test should run on all platforms.
@viettranx viettranx merged commit 551b667 into nextlevelbuilder:main Mar 21, 2026
2 checks passed
duhd-vnpay added a commit to duhd-vnpay/goclaw that referenced this pull request Mar 21, 2026
…Azure OpenAI

Upstream changes (v1.68.1 → v1.74.1, 17 commits):
- feat: pgvector semantic search for KG entities + team KG sharing
- feat: extractive memory fallback when LLM flush fails
- feat: Azure OpenAI + Foundry header support (nextlevelbuilder#319)
- fix: YAML multiline skill frontmatter parsing (nextlevelbuilder#325)
- fix: skills DB file_path directory resolution (nextlevelbuilder#322)
- fix: MCP OpenAI compatibility (nextlevelbuilder#321)
- fix: Windows build + filesystem security (nextlevelbuilder#318)
- feat: MediaMaxBytes enforcement for Telegram/Discord (nextlevelbuilder#317)
- fix: memory embedding cache reliability
- fix: UI usage tab crash, image download overlay
- fix: teams post-turn processor + PendingTeamDispatch

Conflicts resolved:
- internal/agent/loop.go: take upstream (no local changes)
- internal/tools/filesystem.go: take upstream (our comment moved)
- internal/upgrade/version.go: keep ours (28 > upstream 25)
- Removed old filesystem_{unix,windows}.go (replaced by
  filesystem_security_{unix,windows}.go upstream)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants